﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PeliGo.BL;
using PeliGo.DataModel;

namespace PeliGo.UI
{
    public partial class frmLogin : Form
    {
        public frmLogin()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            EmpleadoBL objEmpleadoBL = new EmpleadoBL();
            Empleado loguer = objEmpleadoBL.ObtenerEmpleado(txtUsuario.Text);

            if (loguer != null)
            {
                if (loguer.Clave == txtClave.Text)
                {
                    if (loguer.Rol == 1)
                    {
                        this.Visible = false;
                        txtUsuario.Clear();
                        txtClave.Clear();
                        frmPrincipal_Adm frmP = new frmPrincipal_Adm();
                        frmP.ShowDialog();
                        this.Visible = true;
                    }
                    else if (loguer.Rol == 0)
                    {
                        this.Visible = false;
                        txtUsuario.Clear();
                        txtClave.Clear();
                        frmPrincipal_Caj frmP = new frmPrincipal_Caj();
                        frmP.ShowDialog();
                        this.Visible = true;
                    }
                }
            }
            else
            {
                MessageBox.Show("Ingrese datos válidos", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
    }
}
